function quickSort(arr, left, right) {
    if (left < right) {
        let start = left, // 备份范围
            end = right,
            temp = arr[left]; // 设置基准值
        while (left < right) {
            while (left < right && arr[right] >= temp) right--;
            arr[left] = arr[right];
            while (left < right && arr[left] <= temp) left++;
            arr[right] = arr[left];
        }
        arr[left] = temp;
        quickSort(arr, start, left - 1);
        quickSort(arr, left + 1, end);
    }
}

let arr = [8, 7, 6, 5, 4, 3, 2, 1]
quickSort(arr, 0, arr.length - 1)
console.log(arr)